/* GUI CONVERTED from rcsoisj.p (converter v1.75) Tue Apr 10 12:05:49 2001 */
/* rcsoisj.p - Shipper Confirmation Receive from Final Assembly Order         */
/* Copyright 1986-2002 QAD Inc., Carpinteria, CA, USA.                        */
/* All rights reserved worldwide.  This is an unpublished work.               */
/* $Revision: 1.3.1.2 $                                                       */
/*V8:ConvertMode=Maintenance                                                  */
/* REVISION: 8.6    LAST MODIFIED: 10/17/96   BY: *K003* Forrest Mori         */
/* REVISION: 8.6    LAST MODIFIED: 10/30/97   BY: *K15N* Jim Williams         */
/* REVISION: 8.6    LAST MODIFIED: 05/20/98   BY: *K1Q4* Alfred Tan           */
/* REVISION: 9.1    LAST MODIFIED: 08/12/00   BY: *N0KP* Mark Brown           */
/* $Revision: 1.3.1.2 $   BY: Jean Miller       DATE: 03/22/01  ECO: *P008*   */
/******************************************************************************/
/* All patch markers and commented out code have been removed from the source */
/* code below. For all future modifications to this file, any code which is   */
/* no longer required should be deleted and no in-line patch markers should   */
/* be added.  The ECO marker should only be included in the Revision History. */
/******************************************************************************/

{mfdeclre.i}

/* INPUT VARIABLES */
define input parameter sodnbr    like sod_nbr    no-undo.
define input parameter sodline   like sod_line   no-undo.
define input parameter absline   like abs_line   no-undo.
define input parameter absfalot  like abs_fa_lot no-undo.
define input parameter abssite   like abs_site   no-undo.
define input parameter absloc    like abs_loc    no-undo.
define input parameter abslotser like abs_lotser no-undo.
define input parameter absref    like abs_ref    no-undo.
define input parameter absqty    like abs_qty    no-undo.
define input parameter confirm_mode like mfc_logical no-undo.

/* OUTPUT VARIABLES */
define output parameter sodqtychg like sod_qty_chg no-undo.

/* SHARED VARIABLES */
define new shared variable wo_recno as recid.
define shared variable sod_recno as recid.
define shared variable ship_dt like so_ship_date.
define shared variable change_db like mfc_logical.

if change_db then do:
   find sod_det where
        sod_nbr = sodnbr and
        sod_line = sodline
   exclusive-lock no-error.
end.
else do:
   find sod_det where recid(sod_det) = sod_recno
   exclusive-lock no-error.
end.

/* CLEAR sr_wkfl */
for each sr_wkfl where
         sr_userid = mfguser and
         sr_lineid = absline
exclusive-lock:
   delete sr_wkfl.
end.

/* RECEIVE ASSEMBLE-TO-ORDER ITEM WITH FINAL ASSEMBLY ORDER */
find wo_mstr where
     wo_lot = absfalot and
     wo_type = "F" and
     wo_part = sod_part and
     index("EAR",wo_status) <> 0
no-lock no-error.

if available wo_mstr then do:

   wo_recno = recid(wo_mstr).

   /* CREATE sr_wkfl FOR THE ATO PARENT */
   find sr_wkfl where
        sr_userid = mfguser and
        sr_lineid = absline and
        sr_site = abssite and
        sr_loc = absloc and
        sr_lotser = abslotser and
        sr_ref = absref
   exclusive-lock no-error.

   if not available sr_wkfl then do:
      create sr_wkfl.
      assign
         sr_userid = mfguser
         sr_lineid = absline
         sr_site = abssite
         sr_loc = absloc
         sr_lotser = abslotser
         sr_ref = absref.
   end.

   if recid(sr_wkfl) = -1 then.

   if confirm_mode then
   assign
      sr_qty = absqty / sod_um_conv
      sod_qty_chg = absqty / sod_um_conv.
   else
   assign
      sr_qty = - absqty / sod_um_conv
      sod_qty_chg = - absqty / sod_um_conv.

   sodqtychg = sod_qty_chg.

   /* PROCESS RECEIPT FROM FINAL ASSEMBLY WORK ORDER */
   {gprun.i ""sofarc.p"" "(input sod_nbr, input sod_line)" }
/*GUI*/ if global-beam-me-up then undo, leave.


end.

/* CLEAR sr_wkfl */
for each sr_wkfl where
         sr_userid = mfguser and
         sr_lineid = absline
exclusive-lock:
   delete sr_wkfl.
end.
